﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model;
using jdm.exam.bll;
using System.Web.Security;

namespace jdm.client.Controllers
{
    public class HomeController : Controller
    {
        ExamBLL bll = new ExamBLL();
        //
        // GET: /Home/

        public ActionResult GuanyuPage()
        {
            return View();
        }

        /// <summary>
        /// 登陆界面
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginPage()
        {
            ////直接访问数据库
            ////省略1万字

            ////当你数据访问 完成后 并成功饭后。做下面 票据处理
            //if (true)
            //{
            //    //创造票据
            //    //FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(ac.UserName, false, 1);

            //    //加密票据
            //    //string ticString = FormsAuthentication.Encrypt(ticket);

            //    //输出到客户端
            //    FormsAuthentication.SetAuthCookie(ac.user_name_input, false);

            //    return Redirect(Url.Action("Index", "Home"));
            //}
            //else
            //{

            return View();
            //}
        }


        /// <summary>
        /// 退出登录
        /// </summary>
        /// <returns></returns>
        public ActionResult OnLogin()
        {
            //注销
            FormsAuthentication.SignOut();
            return Redirect(Url.Action("LoginPage", "Home"));
        }

        /// <summary>
        /// 学生登陆后首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_shouye()
        {
            Session["UID"] = ((Usere)Session["Usere"]).U_ID;
            return View();
        }

        /// <summary>
        /// 学生个人信息界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_Gerenxinxi()
        {
           ViewBag.list= Session["Usere"];
            return View();
        }

        /// <summary>
        /// 进入选择试卷管理界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_KaoshiAnniu()
        {
            return View();
        }

        /// <summary>
        /// 考试界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_Kaoshijiemian()
        {
            return View();
        }

        /// <summary>
        /// 考试得分界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_Defen()
        {
            return View();
        }

        /// <summary>
        /// 机试
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_Jishijiemian()
        {
            return View();
        }

        /// <summary>
        /// 进入历史试卷管理界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_LishiAnniu()
        {
            return View();
        }
        /// <summary>
        /// 历史试卷详情
        /// </summary>
        /// <returns></returns>
        public ActionResult Student_Lishishijuan()
        {
            return View();
        }

        /// <summary>
        /// 教师错题管理界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Teacher_CuotiPage()
        {
            Session["UID"] = ((Usere)Session["Usere"]).U_ID;
            return View();
        }

        /// <summary>
        /// 错题汇总
        /// </summary>
        /// <returns></returns>
        public ActionResult Teacher_Cuotihuizong()
        {
            return View();
        }

        /// <summary>
        /// 学生信息界面
        /// </summary>
        /// <returns></returns>
        public ActionResult Teacher_Student()
        {
            return View();
        }

        /// <summary>
        /// 成绩列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Teacher_Chengji()
        {
            return View();
        }

        /// <summary>
        /// 题库管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Tikuguanli()
        {
            return View();
        }

        /// <summary>
        /// 上传试题
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_shangchuan()
        {
            return View();
        }

        /// <summary>
        /// 管理员人员管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Renyuan()
        {
            return View();
        }

        /// <summary>
        /// 权限分配
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Quanxian()
        {
            return View();
        }

        /// <summary>
        /// 考题管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Kaoti()
        {
            return View();
        }

        /// <summary>
        /// 新增组卷策略
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Addzujuan()
        {
            return View();
        }

        /// <summary>
        /// 组卷
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Zujuan()
        {
            return View();
        }

        /// <summary>
        /// 已组成试卷
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin_Yishengcheng()
        {
            Session["UID"] = ((Usere)Session["Usere"]).U_ID;
            return View();
        }
        public int LoginDO(string U_ID,string U_Pwd)
        {
            Usere m = bll.Login(U_ID, U_Pwd);
            Session["Usere"] = m;
            return m.U_State;
        } 

    }
}
